import { setStore, getStore } from '@/utils/store';
export default store => {
	// 初始化时从localStorage获取数据
	const user = getStore("user");
	const Ticket = getStore("Ticket");
	if (user) {
		store.commit('setuser', user);
	}
	if (Ticket) {
		setStore("Ticket", Ticket, true)
	}
	// 用户状态发生变化时缓存之
	store.subscribe((mutation, state) => {
		if (mutation.type === 'setuser') {
			setStore("user", state.user, true);
			setStore("userId", state.userId, true);
		}else if(mutation.type === 'setTicket'){
			setStore("Ticket", state.Ticket, true)
		}
	})
}